<template>  
    <van-form @submit="onSubmit">  
      <van-field  
        v-model="username"  
        name="username"  
        label="用户名"  
        placeholder="请输入用户名"  
        required  
        :rules="[{ required: true, message: '请输入用户名' }]"  
      />  
      <van-field  
        v-model="password"  
        type="password"  
        name="password"  
        label="密码"  
        placeholder="请输入密码"  
        required  
        :rules="[{ required: true, message: '请输入密码' }]"  
      />  
      <div style="margin: 16px;">  
        <van-button round block type="info" native-type="submit">注册</van-button>
         <van-button round block type="info" native-type="submit" to="/login" style="margin-top: 10px;">已有账号，返回登陆</van-button>
      </div>  
    </van-form>  
  </template>  
    
  <script>  
 import { register } from '@/api/user'
export default {
  name: 'LoginPage',
  data () {
    return {
      username: '',
      password: '',
    }
  },
  methods: {
    async onSubmit (values) {
      this.$toast.loading({
        message: '请求中...',
        forbidClick: true
      })

      await register(values)
      this.$toast.success('注册成功')
      this.$router.push('/login')
    }
  }
}

  </script>  
    
  <style scoped>  
  /* 你可以在这里添加一些样式 */  
  </style>